﻿
Namespace PL.MESSDK
    Public Class Appointment_PL
        Inherits PLBase
        Implements IPLProcess, IPLValidation



        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
        End Sub

        Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
            'MsgBox("Appointment_pl :OnRowUpdating ")
        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function

        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()
            'Mandatory Fields
            'TODO: Cache MetaString in AppManager, so here we read it once maybe for nothing
            'Dim ms As MetaString
            'ms = MetaString.GetMetaStringByCode("Mandatory", AppManager.ApplicationOption.LanguageId)
            'If IsDBNull(row("PrdCd")) Then
            '    row.SetColumnError("PrdCd", "Mandatory")
            'End If
            'If IsDBNull(row("PrdDescr_PRM")) Then
            '    row.SetColumnError("PrdDescr_PRM", "Mandatory")
            'End If

            'If IsDBNull(row("PrdDescr_ALT")) Then
            '    row.SetColumnError("PrdDescr_ALT", "Mandatory")
            'End If
            ''


            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub


        Public Function BatchRecords(dataRow() As DataRow) As Boolean Implements IPLProcess.BatchRecords
            Return False
        End Function

        Public Function CurrentRecord(dataRow As DataRow) As Boolean Implements IPLProcess.CurrentRecord
            Return False
        End Function

        Public Function NewRecord(dataRow As DataRow) As Boolean Implements IPLProcess.NewRecord

            If Me.ID IsNot Nothing Then
                dataRow("ID") = ID
            Else
                dataRow("ID") = Guid.NewGuid
            End If

            If IsDBNull(dataRow("Importance")) Then
                dataRow("Importance") = 1
            End If

            Return True

        End Function
    End Class
End Namespace
